﻿using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;

namespace CommonManagement
{
    /// <summary>
    /// 新闻评论管理类
    /// </summary>
    public class CommentManager:DomainService
    {
        private readonly IRepository<Comment, int> _commentRepository;

        public CommentManager(
            IRepository<Comment, int> commentRepository)
        {
            _commentRepository = commentRepository;
        }

        public async Task<Comment> CreateAsync(
            string appType,
            int newsId,
            int userId,
            [NotNull] string content)
        {
            return await _commentRepository.InsertAsync(
                new Comment(
                    appType,
                    newsId,
                    userId,
                    content
                )
            );
        }
    }
}